<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Jhub1_Admin\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Jhub1_Common\Entity\BO\UsersBO;
use Jhub1_Admin\Form\Registration;
use Jhub1_Admin\Model\FormFilter\RegistrationFilter;
use Application\Model\KeyGenerator;
use Zend\Session\Container;
use Jhub1_Admin\Form\AddNewAgent;
use Jhub1_Admin\Model\FormFilter\AddNewAgentFilter;
use Jhub1_Common\Entity\BO\AgentsBO;


class AjaxController extends AbstractActionController
{

    public function localizationformAction()
    {
        $session_user = new Container('user');
        $userPO = $session_user->offsetGet('userobject');
        //localization
        $localizationObj = $userPO->getLocalization();
        $localization = $localizationObj->getObjectVars();

        $view = new ViewModel(array('localization' => $localization));
        $view->setTerminal(true);
        return $view;
    }

    public function personalinfoformAction()
    {
        $session_user = new Container('user');
        $userPO = $session_user->offsetGet('userobject');
        //personal
        $personal = array('email' => $userPO->getEmail(),
            'name' => $userPO->getName(),
            'surname' => $userPO->getSurname()
        );

        $view = new ViewModel(array('personal' => $personal));
        $view->setTerminal(true);
        return $view;
    }

    public function agentslistAction()
    {

        $session_user = new Container('user');
        $userPO = $session_user->offsetGet('userobject');
        $userBO = new UsersBO($this->getServiceLocator());
        $userBO->hydrate($userPO);
        $hydratedUserPO = $userBO->getUserPO();

     //   $hydratedUserPO


        $agents = $hydratedUserPO->getAgents();
     //   $ag = $hydratedUserPO->getAgent(1);
     //   var_dump($ag);
      //  die;

   #    $agentsBO = new AgentsBO($this->getServiceLocator());
#

    #    $agents = $agentsBO->getAgents($userBO->getUserPO());

     //   $agents = $agentsBO->getAgents($userBO->getUserPO());
      #  echo count($agents);
   //     foreach($agents as $agent) {
    ///    echo 'x';
    //   }
     //    die;

   /*

   array(
            'agents' => $agentsBO->getAgents($userBO->getUserPO())
        )
array(
            'agents' => $agents
        )
     $session_user = new Container('user');
        $userPO = $session_user->offsetGet('userobject');
        //personal
        $personal = array('email' => $userPO->getEmail(),
            'name' => $userPO->getName(),
            'surname' => $userPO->getSurname()
        );*/

        $view = new ViewModel(array('agents' => $agents));
        $view->setTerminal(true);
        return $view;
    }

    public function dupkaAction()
    {
        echo "asdasdasdsa";
    }
}